/*
 * @Author: szx
 * @Date: 2022-06-09 14:13:59
 * @LastEditTime: 2022-06-09 14:29:43
 * @Description:
 * @FilePath: \leetcode\面试题\16\15\15.js
 */
/**
 * @param {string} solution
 * @param {string} guess
 * @return {number[]}
 */
var masterMind = function (solution, guess) {
    const cnt = {
        R: 0,
        G: 0,
        B: 0,
        Y: 0
    };
    const res = [0, 0];
    for (let i = 0; i < 4; i++) {
        if (guess[i] == solution[i]) res[0]++;
        else {
            if (cnt[guess[i]]++ < 0) res[1]++;
            if (cnt[solution[i]++ > 0]) res[1]++;
        }
    }
    return res;
};
